import rospy
import sys
import os
from std_msgs.msg import String
path=os.path.abspath(".")
sys.path.insert(0,path)
import tools
"""
节点名称
argv=None argv=sys.argv
anonymous重复启动多个节点 给节点名称最后一个乱码以示区分
"""
rospy.init_node("sanDai",anonymous=True)


pub=rospy.Publisher("pub_api",String,queue_size=10,latch=True)

"""

latch 将最后一条消息保存，当有新的接收方连接到他的时候，将其发送给新的接收方

"""
rospy.loginfo(path)
rospy.loginfo("%d",tools.nums)
msg=String()
rate=rospy.Rate(1)
count=1
if(len(sys.argv)==2):
    count=sys.argv[1][4::]
    count=int(count)

while not rospy.is_shutdown():
    if count<=10:
        msg.data="hello"+str(count)
        pub.publish(msg)
        count+=1
        rate.sleep()